package com.itcoon.cloud.framework.temporal;/**
 * @author Athric Yu
 * 2024/11/15
 **/

import com.itcoon.cloud.framework.properties.TemporalPatternConfigProperties;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 *
 *
 * @author Athric Yu
 * 2024/11/15
 **/
public class StringLocalDateConverter extends AbstractConverter<String, LocalDate>{

    public StringLocalDateConverter(TemporalPatternConfigProperties.TemporalSerialization<String, LocalDate> temporalSerialization) {
        super(temporalSerialization);
    }

    @Override
    public LocalDate parse(String source) {
        return LocalDate.parse(source, DateTimeFormatter.ofPattern(temporalSerialization.getPattern()));
    }

    @Override
    public String format(LocalDate temporal) {
        return temporal.format(DateTimeFormatter.ofPattern(temporalSerialization.getPattern()));
    }
}
